package com.arrays;

import com.Colleciton.CollectionData;
import com.insideClass.Generics.GenericsInterface.Generator;

/**
 * p454
 * @author 13699
 */
public class Generated {
    public static<T> T[] array(T[] a, Generator<T> gen){
        return new CollectionData<T>(gen,a.length).toArray(a);
    }
    @SuppressWarnings("unchecked")
    public static<T> T[] array(Class<T> type,Generator<T> gen,int size){
        T[] a= (T[]) java.lang.reflect.Array.newInstance(type,size);
        return (T[])new CollectionData<T>(gen,size).toArray();
    }
}
